package org.brisling.supply.service;

import java.util.List;

import org.brisling.common.ConstSysParam;
import org.brisling.supply.domain.SupplyBaseType;
import org.brisling.supply.repository.SupplyBasetypeRepo;
import org.brisling.supply.service.base.BaseSupplyTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/supplyBasetype")
public class SupplyBasetypeService extends BaseSupplyTreeService<SupplyBaseType> {
	
	@SuppressWarnings("unused")
	@Autowired
	private SupplyBasetypeRepo baseRepo;

	
	public SupplyBasetypeService(){
		this.moduleName = ConstSysParam.MODULE_SUPPLY_BASETYPE;
		this.clazz = SupplyBaseType.class;
	}
	/* (non-Javadoc)
	 * @see org.brisling.service.sysman.DepartmentServiceInf#getMainPage()
	 */
	@RequestMapping("/mainPage.action")
	public ModelAndView getMainPage(){
		return this.getBizMainPage();
	}
	
	/* (non-Javadoc)
	 * @see org.brisling.service.sysman.DepartmentServiceInf#getEditPage()
	 */
	@RequestMapping("/editPage.action")
	public ModelAndView getEditPage(){
		return this.getBizEditPage();
	}	
	
	
	/* (non-Javadoc)
	 * @see org.brisling.service.sysman.DepartmentServiceInf#getTreeNode(java.lang.Long)
	 */
	@RequestMapping("/getTree.action")
	public List<SupplyBaseType> getTreeNode(@RequestParam(value="id",required=false) Long id){
		return (List<SupplyBaseType>) super.getNode(id);
	}
	/* (non-Javadoc)
	 * @see org.brisling.service.sysman.DepartmentServiceInf#delDepartment(java.lang.Long)
	 */
	@RequestMapping("/del.action")
	public String delRows(@RequestParam(value="id",required=false) Long id){
		
		super.del(id);
		return "200";
	}
	
	/* (non-Javadoc)
	 * @see org.brisling.service.sysman.DepartmentServiceInf#save(java.lang.String)
	 */
	@RequestMapping("/save.action")
	public SupplyBaseType save(@RequestBody String body){
		SupplyBaseType obj = this.bodyToObj(body, SupplyBaseType.class);
		super.save(obj);
		return obj;
	}

}
